<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
<ui:composition template="../templates/layout.xhtml">
    <ui:define name="content">
        <p:growl id="messages" showDetail="false" />
        <h:form prependId="false" enctype="multipart/form-data">
        	 
            <p:panel id="data" header="Release Products">
                 <h:panelGrid id="createPanelGridNew" columns="3" styleClass="dialog" columnClasses="col1,col2,col3">
                 	
                 	<h:outputText id="employeeOutput" value="Employee: * " />
                	<p:selectOneMenu id="employeeMenu" effect="fade" style="width:200px" value="#{productReleaseBean.selectedEmployee}">
                		<f:ajax event="change" render="data" listener="#{productReleaseBean.loadReleasedProductToEmployee}"/>
                		<f:selectItems var="cmb" itemLabel="#{cmb.label}" itemValue="#{cmb.value}" value="#{productReleaseBean.employeeComboList}" />
                	</p:selectOneMenu>
	                <p:message id="employeeMenuMessage" for="employeeMenu" display="icon"/>
	                
	                <h:outputText id="dateOutputCal" value="Date: * " />
	                <p:calendar value="#{productReleaseBean.selectedDate}" id="dateButtonCal" showOn="button" required="true" />
	                <p:message id="dateButtonCalMessage" for="dateButtonCal" display="icon"/>
	                
                 </h:panelGrid>
                 
                 <h:outputFormat id="noRecordsFound" value="#{messages.label_no_records_found}" rendered="#{!productReleaseBean.dataVisible}">
                   <f:param value="Purchases" />
                </h:outputFormat>
                
                <p:dataTable id="list" value="#{productReleaseBean.productReleaseList}" var="productRelease" rendered="#{productReleaseBean.dataVisible}" resizableColumns="false" paginator="false" paginatorTemplate=" {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,25,50" rows="10">
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Release Id" />
                        </f:facet>
                        <h:outputText value="#{productRelease.release_Id}" />
                    </p:column>
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Release Date" />
                        </f:facet>
                        <h:outputText value="#{productRelease.release_Date}" />
                    </p:column>
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Units" />
                        </f:facet>
                        <h:outputText value="#{productRelease.units}" />
                    </p:column>
                    
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Batch No" />
                        </f:facet>
                        <h:outputText value="#{productRelease.stock.purchas.batch_No}" />
                    </p:column>
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Product" />
                        </f:facet>
                        <h:outputText value="#{productRelease.stock.purchas.product.narrative}" />
                    </p:column>
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Product Code" />
                        </f:facet>
                        <h:outputText value="#{productRelease.stock.purchas.product.code}" />
                    </p:column>
                    
                  </p:dataTable>
                  <!-- rendered="#{productReleaseBean.dataVisible}" -->
                	<p:commandButton value="Add"  onclick="releaseDialog.show()"/>
            </p:panel>
       </h:form>
            <p:dialog id="addDialog" header="Release Product" modal="true" widgetVar="releaseDialog" resizable="false" showEffect="fade" hideEffect="fade" >
            <!--  <p:ajax event="close" update="list" listener="#{toppingBean.handleDialogClose}" />  -->
            <h:form id="releaseForm" prependId="false" enctype="multipart/form-data">
                <p:growl id="messages2" showDetail="false" />
                <h:panelGrid id="releasePanelGrid" columns="3" styleClass="dialog" columnClasses="col1,col2,col3" >
                	<p:autoComplete value="#{productReleaseBean.selectedProductAutoComplete}" id="productAutoCmplt" completeMethod="#{productReleaseBean.completeProduct}"  
                    var="p" itemLabel="#{p.label}" itemValue="#{p.value}" forceSelection="true">
                    	<p:ajax event="itemSelect" update="messages2" listener="#{productReleaseBean.handleProductSelect}"/>
                    </p:autoComplete>
                </h:panelGrid>
                
                <p:dataTable id="stockList" value="#{productReleaseBean.stockList}" var="stock" resizableColumns="false" paginator="false" paginatorTemplate=" {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,25,50" rows="10">
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Product Code" />
                        </f:facet>
                        <h:outputText value="#{stock.purchas.product.code}" />
                    </p:column>
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Product Name" />
                        </f:facet>
                        <h:outputText value="#{stock.purchas.product.narrative}" />
                    </p:column>
                    
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Batch No" />
                        </f:facet>
                        <h:outputText value="#{stock.purchas.batch_No}" />
                    </p:column>
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Units" />
                        </f:facet>
                        <h:outputText value="#{stock.units}" />
                    </p:column>
                    
                    
                    <p:column>
                    	<f:facet name="header">
                            <h:outputText value="Release Units" />
                        </f:facet>
                        <p:inputText value="#{stock.units}"/>
                    </p:column>
                    
                   
                    
                  </p:dataTable>
                  
                <!-- <p:commandButton value="#{messages.label_save}" action="#{toppingBean.persist}" update="releasePanelGrid messages" />  -->
                <p:commandButton value="#{messages.label_close}" onclick="releaseDialog.hide()" type="button" />
            </h:form>
        </p:dialog>
        
        
        
        
       
    </ui:define>
</ui:composition>
</html>